package com.ck.util;

import com.ck.constant.RequestConstant;
import com.ck.model.common.User;
import com.ck.model.common.sys.LoginUser;

import javax.servlet.http.HttpServletRequest;

/**
 * session工具类
 *
 * @author linqiang
 * @version v1.0
 * @date 2018-09-11 13:34
 */
public class SessionUtils {

    /**
     * 获取登录用户信息
     *
     * @param request 请求
     * @return LoginUser
     */
    public static LoginUser getLoginUserInfo(HttpServletRequest request) {
        User user = (User) request.getSession().getAttribute(RequestConstant.SESSION_KEY_USER);
        String ip = HttpUtils.getRemortIP(request);
        LoginUser loginUser = new LoginUser();
        loginUser.setIp(ip);
        loginUser.setUser(user);
        return loginUser;
    }
}
